package com.cat.greedyAlgorithm;

import java.util.HashMap;

/**
*   @description https://leetcode.cn/problems/minimum-number-of-days-to-eat-n-oranges/
*   @author 曲大人的喵
*   @create 2025/8/25 16:47
*   @since JDK17
*/

public class Solution37 {
    static HashMap<Integer, Integer> dp = new HashMap<>();
    public int minDays(int n) {
        if (n <= 1) {
            return n;
        }
        if (dp.containsKey(n)) {
            return dp.get(n);
        }
        int ans = Math.min(n % 2 + 1 + minDays(n / 2), n % 3 + 1 + minDays(n / 3));
        dp.put(n, ans);
        return ans;
    }
}
